<?php
//error_reporting(E_ALL);
//ini_set('display_errors', '1');

session_start();
?>
<?php
		include_once('config/db_conn.php');
		include_once('db_config/db_gigs.php');
		include_once('db_config/db_user.php');
		include_once('db_config/db_websetting.php');
		include_once('db_config/db_multiple_gigs.php');
		
		$websetting= new websetting();
		$user=new user();
		$gigs=new gigs();
		$multiple_gigs =new multipleGigs();
		$rs_multiple_gigs=$multiple_gigs->multiple_gigs_list();

		$websetting_id = '1';
		$rs_websetting=$websetting->uniq_websettings('websetting_id',$websetting_id);
		$data_websetting=mysql_fetch_array($rs_websetting);

		/*For  Pagination */

		$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
		$page = ($page == 0 ? 1 : $page);
		$perpage = 10;//limit in each page
		$startpoint = ($page * $perpage) - $perpage;


		/*---------------*/


/*		$gigs_data['gigs_title'] = '';
		$gigs_data['catagory_id'] = '';
		$fldArray['catagory_id'] = '';
		$orderArray['catagory_id'] = '';
		$orderArray['gigs_title'] = '';
		$extra=' ';
		$orderType='desc';
		$offset=0;
		$limit=20;
		$gigs->dataSelect('ninerr_gigs',$gigs_data,$fldArray,$extra,$orderArray,$orderType,$limit,$offset);*/


		//$rs=$gigs->gigs_list();
		if(@$_REQUEST['tags']!='')
		{
			$rs=$gigs->uniq_gigs_list_limit_like('gigs_keywords_tags',$_REQUEST['tags'],$startpoint,$perpage);
		}
		elseif(@$_REQUEST['gigs']=='latest')
		{
			$rs=$gigs->uniq_gigs_list_orderby('gigs_date','ASC','user_id!',$_SESSION['user_id'],$startpoint,$perpage);
			$class1='link_select';
		}
		elseif(@$_REQUEST['gigs']=='rating')
		{
			$rs=$gigs->uniq_gigs_list_limit('gigs_rate','10',$startpoint,$perpage);
			$class3='link_select';
		}
		elseif(@$_REQUEST['gigs']=='popular')
		{
			$rs=$gigs->uniq_gigs_list_limit('gigs_like','like',$startpoint,$perpage);
			$class2='link_select';

		}
		else
		{
			$rs=$gigs->uniq_gigs_list_limit('user_id!',@$_SESSION['user_id'],$startpoint,$perpage,'featured');

		}
		if(@$_REQUEST['m_gigs_id']!='')
		{
			$m_gigs_id=$_REQUEST['m_gigs_id'];
			$rs=$gigs->uniq_gigs_list_limit('multiple_gigs_id',$_REQUEST['m_gigs_id'],$startpoint,$perpage);
		}
		$i=0;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SITE_NAME; ?></title>
<meta name="description" content="<?php echo SITE_NAME; ?> Where moms like you swap kid's clothing and toys online" />
<meta name="swap clothes,clothing swap,used clothing,secondhand,kids,children,clothes, kids clothing, baby clothes,	consignment" content="online clothes and toys swapping website" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" name="created by Georgeleem.com" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="javascript/jquery.min.js"></script>
<script type="text/javascript" src="javascript/jquery.simplemodal.js"></script>
<script type="text/javascript" src="javascript/init.js"></script>
<script type="text/javascript" src="javascript/init1.js"></script>
<script src="javascript/main.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="javascript/ajax.js"></script>
<script language="javascript" type="text/javascript">
//<![CDATA[

        function like_click(str,id)
        {
                //document.getElementById("search_div").innerHTML='';
                loadFragmentInToElement('gigs_like_update.php?id='+id+'&val='+str,'search_div'+id,'');


        }


//]]>
</script>
<script language="javascript" type="text/javascript">
//<![CDATA[
        /* this is just a simple reload; you can safely remove it; remember to remove it from the image too */
        function reloadCaptcha()
        {
                document.getElementById('captcha').src = document.getElementById('captcha').src+ '?' +new Date();
        }
//]]>
</script>
<script language="javascript" type="text/javascript">
//<![CDATA[
function openCenteredWindow(url) {
        parms = 'menubar=no,width=600,height=500,toolbar=no'
        name = "facebook_share"
        height=500
        width=600
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   return win;
}
//]]>
</script>

<!--<link type='text/css' href='css/stylesheet.css' rel='stylesheet' media='screen' />
<link type='text/css' href='css/basic.css' rel='stylesheet' media='screen' />
<link rel="stylesheet" type="text/css" href="css/style1.css" />-->
</head>
<body>

<div id="container" class="content">

<!--HEADER AREA-->
<?php include('header.php')?>
<!--HEADER AREA END-->
<div id="main" class="clearfix">
	<div class="main-tl">
	  	<div class="main-tr"></div>
	  	<div class="main-top"></div>
	</div>
	<div class="main-inner clearfix">
		<div class="side1">
<!-- side1 content BEGIN ====================== -->
<div class="banner">
	<img src="images/img/banner.jpg" title="Banner" alt="[Image: Banner]" /> 
	<a href="how_work.php" class="js-how-it-works-colorbox cboxElement" title="How does it work?">How does it work?</a>
</div>	
<br />
<!-- search BEGIN -->
	<?php
if(@$_SESSION['username_email']!='')
{
?>
	<div id="gigs-index" class="gigs form js-responses">
		<form method="post" id="GigAddForm" enctype="multipart/form-data"  action="manage_gigs.php" class="normal">
			<h2>What are you willing to do?</h2>
			<span class="will-info">I Will</span>
			<div class="input text required">
				<input type="text" name="gigs_title" id="gigs_title" value="" maxlength="255" /> for 
				<select name="multiple_gigs_id" id="multiple_gigs_id">
				<?php
				while($data_multiple_gigs=mysql_fetch_array($rs_multiple_gigs))
				{
				?>	
                    <option value="<?php  echo $data_multiple_gigs['multiple_gigs_id'];?>"
					<?php if($data_multiple_gigs['multiple_gigs_id'] == 1)
					{
						echo 'selected';

					}?>
					><?php  echo $data_multiple_gigs['multiple_gigs_price'];?></option>
				<?php
				}
				?>
              	</select>
			</div>			
			<div class="submit-block clearfix">
				<div class="submit"><input type="submit" value="Continue" /></div>			
			</div>
	    </form>
	</div>
	<?php
}
?>
<!-- search END -->
<!-- filter begin -->
<div class="tweet_bx">
 <form method="post" name="m_gigs" id="m_gigs" enctype="multipart/form-data"  action="index.php">
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="17%"><strong>Filter gigs by</strong></td>
	<td class="<?php echo $class1;  ?>" width="8%" align="center" ><a class="cuuuent" href="index.php?gigs=latest" >Latest</a></td>
	<td class="<?php echo $class2;  ?>" width="15%" align="center"><a href="index.php?gigs=popular">Most Popular</a></td>
	<td class="<?php echo $class3;  ?>" width="15%" align="center"><a href="index.php?gigs=rating" >Best Ratings</a></td>
	<td  width="45%" align="right">Job Price: <select name="m_gigs_id" id="m_gigs_id" onchange="m_gigs.submit();">
				<option value="">Please choose</option>
				<?php
				$rs_m_gigs=$multiple_gigs->multiple_gigs_list();
				while($data_m_gigs=mysql_fetch_array($rs_m_gigs))
				{

				?>

                    <option value="<?php  echo $data_m_gigs['multiple_gigs_id'];?>"
					<?php if(@$m_gigs_id == $data_m_gigs['multiple_gigs_id']){
						echo 'selected';
					}?>
					><?php  echo $data_m_gigs['multiple_gigs_price'];?></option>


				<?php
				}
				?>
                  </select></td>
  </tr>
</table>
</form>
</div>
<!-- filter end -->
<!-- list gig BEGIN =======================================================================-->
<ol class="list">
<?php
$page_cnt = 0;
while($data=mysql_fetch_array($rs))
{
	$rs_user=$user->uniq_user_list('user_id',$data['user_id']);
	$data_user=mysql_fetch_array($rs_user);
	$page_cnt = $page_cnt + 1;	
	$rs_mul_gigs=$multiple_gigs->uniq_multiple_gigs('multiple_gigs_id',$data['multiple_gigs_id']);
	$data_mul_gigs=mysql_fetch_array($rs_mul_gigs);
	
	if($data_user['user_name']!='')
	{
	?>
	<li class="clearfix">
		<div class="side1-info-l">
			<!----Featured User---->
          <?php
		  if($data['gigs_featured']=='Y')
		  {
		  ?>
	          <span class="featured">&nbsp;</span>	
	          <?php
		  }
		  ?>
          <!--End of Featured User-->			
			<p>
				<a href="users_<?php echo $data_user['user_name']; ?>_gigs_<?php  echo str_replace(' ','-', $data['gigs_title']);?>">
					<img src="gigsimg/<?php
						if($data['gigs_image'])
						echo $data['gigs_image'];
						else echo 'no_img.jpg' ?>" class="" alt="[Image: <?php echo $data['gigs_title']; ?>]" title="<?php echo $data['gigs_title'].' for $20'; ?>" width="106" height="76" />
				</a>
			</p>
		</div>
		<div class="side1-info-r">
			<h3>
				<a href="users_<?php echo $data_user['user_name']; ?>_gigs_<?php  echo str_replace(' ','-', $data['gigs_title']);?>" title="<?php  echo  $data['gigs_title'].' for '. $data_mul_gigs['multiple_gigs_price']; ?>"><span class="c">I will <?php  echo  $data['gigs_title'];?> for <?php echo $data_mul_gigs['multiple_gigs_price']; ?></span></a>	
			</h3>
			<p><?php  echo substr($data['gigs_description'],0,50);?>...<span> (by <a href="#" title="<?php echo $data_user['user_name']; ?>"><span class="c"><?php echo $data_user['user_name']; ?></span></a>)</span></p>
			<ul class="list1 clearfix">
	            <li class="read-more">
					<a href="users_<?php echo $data_user['user_name']; ?>_gigs_<?php  echo str_replace(' ','-', $data['gigs_title']);?>" title="Read more">Read more</a>	
				</li>					
	            <li class="read-more1">
					<a href="#" title="Like" class="like js-ajax-colorbox {source:&quot;js-dialog-body-login&quot;} cboxElement">Like</a>				</li>					
				<li class="share">
					<span title="Share" class="js-share-toggle-check">Share</span>
					<div style="display: block;">
						<ul class="share-list">
							<li class="facebook"><a href="#" onClick="openCenteredWindow('http://www.facebook.com/sharer.php?u=<?php echo 'http://'.$_SERVER['HTTP_HOST'];?>/users_<?php echo $data_user['user_name']; ?>_gigs_<?php echo str_replace(' ','-', $data['gigs_title']); ?>');" title="Share this gig in facebook" class="face">facebook</a></li>
							<li class="twitter"><a href="http://www.twitter.com/?status=<?php echo $data_user['user_name']; ?>:<?php  echo str_replace(' ','+', $data['gigs_title']);?>+<?php echo "http://".$_SERVER['HTTP_HOST']; ?>/users_<?php echo $data_user['user_name']; ?>_gigs_<?php  echo str_replace(' ','-', $data['gigs_title']);?>" target="blank" title="Tweet this gig" class="tweet">twitter</a></li>
							<li class="email"><a href="mailto:<?php echo $data_user['user_primary_email']; ?>?subject=<?php  echo str_replace(' ','%20', $data['gigs_title']);?>&amp;body=Hi,%0A%0ACheck%20it%20out:%20<?php echo "http://".$_SERVER['HTTP_HOST']; ?>/users_<?php echo $data_user['user_name']; ?>_gigs_<?php  echo str_replace(' ','-', $data['gigs_title']);?>" target="blank" title="mail" class="quick">email</a></li>
						</ul>
					</div>
				</li>				
				<li class="order-but">
					<a href="users_<?php echo $data_user['user_name']; ?>_gigs_<?php  echo str_replace(' ','-', $data['gigs_title']);?>" title="Order Now" class="js-ajax-colorbox {source:&quot;js-dialog-body-login&quot;} cboxElement">Order Now</a>					
				</li>
			</ul>
		</div>
	</li>
	<?php
	} // end if
} // end while
	?>
</ol>
<!-- list gig END ======================================================================================= -->
<!-- old code begin -->
<div class="tweet_bx">
<?php


	//show pages

	if(@$_REQUEST['gigs']=='latest')
	{
		$page_name='index.php?gigs=latest&';
	}
	elseif(@$_REQUEST['gigs']=='rating')
	{
		$page_name='index.php?gigs=rating&';
	}
	elseif(@$_REQUEST['gigs']=='popular')
	{
		$page_name='index.php?gigs=popular&';

	}
	elseif(@$_REQUEST['tags']!='')
	{
		$page_name='index.php?tags='.$_REQUEST['tags'].'&';
	}
	elseif(@$_REQUEST['m_gigs_id']!='')
	{
		$page_name='index.php?m_gigs_id='.$_REQUEST['m_gigs_id'].'&';
	}
	else
	{
		$page_name='index.php?';
	}
	if($page_cnt >= $perpage)
		echo Pages("ninerr_gigs",$perpage,$page_name,$_SESSION['user_id']);


?>

</div>
<!-- OLD CODE END ============================================================== -->
</div><!-- end side1 -->

<?php include('right.php'); ?>
</div><!-- end main-inner-->
</div><!-- end main -->

<!--FOOTER AREA-->
<?php include('footer.php');?>
 <!--FOOTER AREA END-->

</div>

</body>
</html>